#include<iostream>
#include<string>
#include<unordered_map>
using namespace std;
const int N = 1e6 + 10;
int a[N];
int main()
{
	int t, n = 0;
	cin >> t;
	//值--出现次数 
	while (t--)
	{
		cin >> n;
		unordered_map<int, int> hash;
		for (int i = 1; i <= n; i++) cin >> a[i];
		int left = 1, right = 1, ret = 0;
		while (right <= n)
		{
			int key = a[right];
			//进窗口
			hash[key]++;
			while (hash[key] > 1)
			{
				//出窗口
				hash[a[left]]--;
				++left;
			}
			ret = max(ret, right - left + 1);
			++right;
		}
		cout << ret << endl;
	}
	return 0;
}